const HomeService = require('../service/home')

module.exports = {
  index: async(ctx, next) => {
    let res = await HomeService.index()
    // console.log(res)
    await ctx.render("stock/index", res.data)
  },
  aistock: async(ctx, next) => {
    await ctx.render('stock/aistock', {
      btnName: 'GoGoGo'
    })
  },
  login: async(ctx, next) => {
    await ctx.render('stock/login', {
      btnName: 'GoGoGo'
    })
  },
  register: async(ctx, next) => {
    let params = ctx.request.body
    let name = params.name
    let password = params.password
    let res = await HomeService.stockregister(name,password)
    if(res.status == "-1"){
      await ctx.render("stock/login", res.data)
    }else{
      ctx.state.title = "个人中心"
      await ctx.render("stock/index", res.data)
    }
  }
}